package test;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class test02 {
    JFrame frame=new JFrame();
    public void init() {
        frame.setSize(500, 500);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JSplitPane splitPane = new JSplitPane();
        splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
        splitPane.setDividerLocation(200);
        splitPane.setLeftComponent(new JLabel("1"));

        JButton button=new JButton("hjiu");
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JPanel panel=new JPanel();
                panel.add(new JLabel("12"));
//                frame.removeAll();
                frame.remove(splitPane);
                frame.add(panel);
                frame.revalidate();
                frame.repaint();
            }
        });

        splitPane.setRightComponent(button);
        frame.add(splitPane);

        frame.setVisible(true);
    }

    public static void main(String[] args) {
        new test02().init();
    }
}
